﻿@model Customer

<h3 style="color:red;">Quản Lý Khách Hàng</h3>
<br/>
<div role="tabpanel">

    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#edit" aria-controls="edit" role="tab" data-toggle="tab">Thêm Khách Hàng &nbsp;<span class="glyphicon glyphicon-home"></span> </a></li>
        <li role="presentation"><a href="#list" aria-controls="list" role="tab" data-toggle="tab">Danh Sách khách Hàng &nbsp;<span class="glyphicon glyphicon-phone"></span></a></li>
    </ul>

    <!-- Tab panes -->
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="edit">
            <h4>@Html.ValidationSummary()</h4>
            @using (Html.BeginForm("Insert", "Customers",
    FormMethod.Post, new { enctype = "multipart/form-data" }))
            {
                <div class="row">
                   
                    <div class="col-md-4">
                        <div class="form-group">
                            <div>Tên Đăng Nhập</div>
                            @Html.TextBoxFor(s => s.Id,new { @class = "form-control"})
                        </div>
                        <div class="form-group">
                            <div>Mật Khẩu</div>
                            @Html.PasswordFor(s => s.Password,new { @class = "form-control"})
                        </div>

                        <div class="form-group">
                            <div>Họ Tên</div>
                            @Html.TextBoxFor(s => s.Fullname,new { @class = "form-control"})
                        </div>

                        <div class="form-group">
                            <div>Email</div>
                            @Html.TextBoxFor(s => s.Email,new { @class = "form-control"})
                        </div>
                        <div class="form-group">
                            <div>Kích Hoạt</div>
                            @Html.CheckBoxFor(s => s.Activated, new { @class = "form-control" })
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="form-group">
                            <div>Hình Ảnh</div>
                            <img style="width:283px;height:310px;" src="/images/customers/@Model.Photo" /><br />
                            <input type="file" name="UpPhoto" />
                            @Html.HiddenFor(s => s.Photo)
                        </div>
                    </div>
                </div>
                

                

               
                

                <div class="form-group">
                    <div></div>
                    <div>
                        <button onclick="form.action = '/Admin/Customers/Insert'" class="btn btn-default">Insert</button>
                        @if (!String.IsNullOrEmpty(Model.Id))
                        {
                            <button onclick="form.action = '/Admin/Customers/Update'" class="btn btn-default">Update</button>
                                  <a href="/Admin/Customers/Delete/@Model.Id" onclick="return Xoa();" class="btn btn-default">Delete</a>
                        }
                        <a href="/Admin/Customers/Index" class="btn btn-default">Reset</a>
                    </div>
                </div>
            }
        </div>
        <div role="tabpanel" class="tab-pane" id="list">
            <br/><br />
            <table class="table table-hover">
                <tr>
                    <th>Tên Đăng Nhâp</th>
                    <th>Mật Khẩu</th>
                    <th>Họ Tên</th>
                    <th>Email</th>
                    <th>Hình Ảnh</th>
                    <th>Kích Hoạt</th>
                    <th></th>
                </tr>
                @foreach (var s in ViewBag.Customers)
                {
                    <tr>
                        <td>@s.Id</td>
                        <td>@s.Password</td>
                        <td>@s.Fullname</td>
                        <td>@s.Email</td>
                        <td><img style=" width: 100px; height: 50px;" src="~/images/customers/@s.Photo" /></td>
                        <td>@s.Activated</td>
                        <td>
                            <a href="/Admin/Customers/Edit/@s.Id"
                               class="btn btn-default">Edit</a>
                            <a href="/Admin/Customers/Delete/@s.Id" onclick="return Xoa();" class="btn btn-default">Delete</a>
                        </td>
                    </tr>
                }
            </table>
        </div>
    </div>

</div>






@section scripts{

<script>
    function Xoa() {
        var ok = confirm("Có chắc chắn xóa mẫu tin có mã  không?");
        if (ok == true) {
            window.location.href = "/Admin/Customers/Delete/@Model.Id";
        } else {
            return false;
        }
    }
</script>
}
